package org.nlp2rdf.navigator.benchmark.pools;

import com.hp.hpl.jena.rdf.model.Resource;
import org.aksw.commons.semweb.sparql.core.ISparqlEndpoint;
import org.nlp2rdf.navigator.benchmark.MySparqlTasks;
import org.nlp2rdf.navigator.benchmark.PoolUtils;
import org.nlp2rdf.navigator.benchmark.Sample;

import java.util.Random;
import java.util.Set;

/**
 * Created by Claus Stadler
 * Date: Oct 25, 2010
 * Time: 1:00:54 AM
 */
public class HistoryPoolFactory
    implements IPoolFactory
{
    private ISparqlEndpoint sparqlEndpoint;
    private Set<String> graphNames;
    private Random random;

    public HistoryPoolFactory(ISparqlEndpoint sparqlEndpoint, Set<String> graphNames, Random random)
    {
        this.sparqlEndpoint = sparqlEndpoint;
        this.graphNames = graphNames;
        this.random = random;
    }

    @Override
    public Sample<Resource> createPool(Resource id) {
        Set<Resource> positives = MySparqlTasks.getTypedDBpediaCategoryMembers(sparqlEndpoint, graphNames, id);

        return PoolUtils.generateNavigationPool(sparqlEndpoint, graphNames, id, positives, random);
    }
}
